ik_llama.cpp has a minimal set of dependencies: cmake, a C++17-capable compiler, and — for GPU builds — the CUDA toolkit. All are available from the system package manager on Linux.
Prerequisites
- Linux (Debian/Ubuntu)
- macOS
- Windows
- FreeBSD
CMake build
CMake is the recommended build method on all platforms.- CPU-only (Linux/macOS)
- CUDA (Nvidia GPU)
- Metal (macOS)
- Windows (x64)
- Android / ARM
Important CMake flags
-DGGML_NATIVE=ON
-DGGML_NATIVE=ON
Detects your CPU’s feature set at compile time (AVX2, AVX-512, ARM NEON, etc.) and generates optimised code for it. Highly recommended for local builds. Omit this flag if you need a portable binary that runs on older CPUs.
-DGGML_CUDA=ON
-DGGML_CUDA=ON
Enables the CUDA backend for Nvidia GPU acceleration. Requires the CUDA Toolkit to be installed.
-DCMAKE_CUDA_ARCHITECTURES=<arch>
-DCMAKE_CUDA_ARCHITECTURES=<arch>
Limits CUDA compilation to specific GPU compute capabilities, dramatically reducing build time. Common values:
Example:
-DCMAKE_CUDA_ARCHITECTURES=86-DGGML_IQK_FA_ALL_QUANTS=ON
-DGGML_IQK_FA_ALL_QUANTS=ON
Compiles support for all KV cache quantization type combinations in the Flash Attention CUDA kernels. Enables more fine-grained control over KV cache size (e.g. using
IQ4_K for K-cache and IQ3_K for V-cache together with Flash Attention). Significantly increases compilation time.-DGGML_RPC=ON
-DGGML_RPC=ON
Enables the RPC backend, which allows offloading compute to a remote machine. Useful in distributed or heterogeneous multi-machine setups.
-DGGML_NCCL=OFF
-DGGML_NCCL=OFF
Disables NCCL (NVIDIA Collective Communications Library) support. NCCL is off by default; set this explicitly if your environment has NCCL installed and you want to avoid linking it.
-DLLAMA_SERVER_SQLITE3=ON
-DLLAMA_SERVER_SQLITE3=ON
Enables SQLite3 support in
llama-server, required for the mikupad alternative web UI. Make sure libsqlite3-dev (or equivalent) is installed before configuring.Debug builds
Debug builds
For single-config generators (default on Linux/macOS):For multi-config generators (Visual Studio, Xcode):
Windows build
The following is a step-by-step walkthrough for a successful Windows CUDA build using clang-cl via Visual Studio Build Tools.1
Install CUDA Toolkit and Visual Studio Build Tools
- Download CUDA 12.6 from Nvidia. During installation, select custom setup and uncheck Driver components and PhysX (not needed in a VM).
- Download Visual Studio Build Tools 2022. During setup, go to the Individual components tab, search for
clang, and add the clang-related tools (they are not selected by default).
2
Clone the repository
Download Portable Git and clone:
3
Set up environment variables
4
Configure with CMake
Adjust
-DCMAKE_CUDA_ARCHITECTURES to match your GPU and /clang:-march= to match your CPU:Use forward slashes (
/) in all cmake paths on Windows. Backslashes can be misinterpreted by CMake as escape characters.5
Build
6
Copy CUDA runtime DLLs
Copy the following DLLs from
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin to C:\Downloads\output\bin:cublas64_12.dllcublasLt64_12.dllcudart64_12.dll
libomp140.x86_64.dll from C:\Windows\System32\ to the same output bin directory.BLAS acceleration
Building with BLAS support can improve prompt processing throughput for large batch sizes (above 32 tokens). It does not affect token generation speed on CPU-only builds.OpenBLAS (Linux)
OpenBLAS (Linux)
libopenblas-dev (or equivalent) is installed first.Intel oneMKL
Intel oneMKL
Source the oneAPI environment and then build:If you are using the oneAPI-basekit Docker image, you can skip the
setvars.sh step.Accelerate Framework (macOS)
Accelerate Framework (macOS)
Accelerate is enabled by default on macOS — no extra flags are needed. Use the standard CMake build instructions.
hipBLAS / ROCm
Install ROCm first. Then build, specifying your AMD GPU target:- Linux (CMake)
- Windows (CMake)
HIP_VISIBLE_DEVICES selects which GPU(s) to use at runtime. If your GPU is not officially supported, try setting HSA_OVERRIDE_GFX_VERSION to a similar architecture (e.g. 10.3.0 for RDNA2, 11.0.0 for RDNA3).
Vulkan
- Linux (Ubuntu)
- Windows (MSYS2)
- Docker
Install the Vulkan SDK:Then build: